import request from '@/utils/request'

// 盘点单列表
export function stocktakingList(data) {
    return request({
        url: '/system/stocktakingOrder/list',
        method: 'get',
        params: data
    })
}

// 新建盘点单
export function stocktakingAdd(data) {
    return request({
        url: '/system/stocktakingOrder/add',
        method: 'post',
        data: data
    })
}

// 编辑盘点单
export function stocktakingEdit(data) {
    return request({
        url: '/system/stocktakingOrder/edit',
        method: 'post',
        data: data
    })
}

// 获取盘点单详细信息
export function stocktakingDetail(id) {
    return request({
        url: '/system/stocktakingOrder/getInfo?id=' + id,
        method: 'get'
    })
}

// 审核
export function stocktakingCheck(id, status, approveStatus, approveRemark) {
    const data = {
        id,
        status,
        approveStatus,
        approveRemark
    }
    return request({
        url: '/system/stocktakingOrder/check',
        method: 'post',
        data: data
    })
}

// 根据仓库搜索sku列表
export function searchWarehouseSku(data) {
    return request({
        url: '/system/productStorage/getStorageByWarehouseId',
        method: 'get',
        params: data
    })
}

// 根据仓库搜索列表分类
export function searchWarehouseSort(id) {
    return request({
        url: '/system/productBasicSort/getSortByWarehouseId?warehouseId=' + id,
        method: 'get'
    })
}

// 开始盘点
export function startStocktaking(id) {
    return request({
        url: '/system/stocktakingOrder/startInventory?id=' + id,
        method: 'get'
    })
}

// 结束盘点
export function endStocktaking(id) {
    return request({
        url: '/system/stocktakingOrder/endInventory?id=' + id,
        method: 'get'
    })
}

// 再次盘点
export function againStocktaking(id) {
    return request({
        url: '/system/stocktakingOrder/againInventory?id=' + id,
        method: 'get'
    })
}

// 结束确定再次盘点
export function endAgainStocktaking(id) {
    return request({
        url: '/system/stocktakingOrder/secondInventory?id=' + id,
        method: 'get'
    })
}

// 确认差异
export function confirmDifferenceStocktaking(id) {
    return request({
        url: '/system/stocktakingOrder/confirmDifference?id=' + id,
        method: 'get'
    })
}

// 结果确定
export function resultConfirm(data) {
    return request({
        url: '/system/stocktakingOrder/resultConfirm',
        method: 'post',
        data: data
    })
}

// 撤销确定
export function revokeConfirm(id) {
    return request({
        url: '/system/stocktakingOrder/revokeConfirm?id=' + id,
        method: 'get'
    })
}

// 扫码盘点
export function scanCode(data) {
    return request({
        url: '/system/stocktakingOrder/stocktaking',
        method: 'post',
        data: data
    })
}

// 删除盘点
export function deleteScanCode(data) {
    return request({
        url: '/system/stocktakingOrder/deleteScanCode',
        method: 'post',
        data: data
    })
}

// 编辑盘点数据
export function stocktakingDataEdit(data) {
    return request({
        url: '/system/stocktakingDetail/edit',
        method: 'post',
        data: data
    })
}